package com.suntront.module_mine.home

import android.app.Dialog
import android.os.Message
import android.view.View
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.mtjsoft.www.kotlinmvputils.base.BaseActivity
import com.mtjsoft.www.kotlinmvputils.constants.RouterConstants
import com.mtjsoft.www.kotlinmvputils.imp.AndDialogClickListener
import com.mtjsoft.www.kotlinmvputils.utils.AndActivityUtils
import com.mtjsoft.www.kotlinmvputils.utils.AndDialogUtils
import com.suntront.module_mine.R
import kotlinx.android.synthetic.main.activity_admin_detail.*

/**
 * 个人中心
 * @author mtj
 * @Package com.suntront.module_mine.home
 * @date 2020-05-27 14:22:09
 */
@Route(path = RouterConstants.MINE_ACTIVITY)
class MineActivity : BaseActivity<MineViewModel>() {

    override fun layoutResId(): Int {
        return R.layout.activity_admin_detail
    }

    override fun initView() {
        setPageTitle("个人信息")
    }

    override fun initData() {
        viewModel.setNameAndAccount(admin_detail_name, admin_detail_code)
    }

    override fun providerVMClass(): Class<MineViewModel>? {
        return MineViewModel::class.java
    }

    override fun onClick(p0: View) {
        super.onClick(p0)
        when (p0.id) {
            R.id.admin_detail_quit -> {
                // 退出登录
                AndDialogUtils.builder(getContext())
                    .buildCanCancel(true)
                    .buildCancelClickListener(null)
                    .buildMsg("确认要退出当前账号吗？")
                    .buildSureClickListener(object : AndDialogClickListener {
                        override fun onClick(paramDialog: Dialog, paramView: View) {
                            paramDialog.dismiss()
                            ARouter.getInstance().build(RouterConstants.LOGIN_ACTIVITY).navigation()
                            AndActivityUtils.instance.clearActivity()
                        }
                    })
                    .buildShowAll(true)
                    .showDialog()
            }
        }
    }

    override fun processHandlerMsg(msg: Message) {
    }
}